package fudan.se.lab2.controller;

import fudan.se.lab2.controller.request.DistributeRequest;
import fudan.se.lab2.domain.Contribution;
import fudan.se.lab2.domain.Distribution;
import fudan.se.lab2.service.DistributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DistributeController {
    private final DistributeService distributeService;

    @Autowired
    public DistributeController(DistributeService distributeService) {
        this.distributeService = distributeService;
    }

    @PostMapping("/distribute")
    public ResponseEntity<Boolean> distribute(@RequestBody DistributeRequest request) {
        return ResponseEntity.ok(distributeService.distribute(request));
    }

    @PostMapping("/contributionToBeReviewed")
    public ResponseEntity<List<Contribution>> contributionToBeReviewed(@RequestBody String username) {
        return ResponseEntity.ok(distributeService.contributionToBeReviewed(username));
    }

    @PostMapping("/contributionToBeCheckReviewedFirstly")
    public ResponseEntity<List<Contribution>> contributionToBeCheckReviewedFirstly(@RequestBody String username) {
        return ResponseEntity.ok(distributeService.contributionToBeCheckReviewedFirstly(username));
    }

    @PostMapping("/contributionsWaitingForRebuttal")
    public ResponseEntity<List<Contribution>> contributionsWaitingForRebuttal(@RequestBody String username) {
        return ResponseEntity.ok(distributeService.contributionsWaitingForRebuttal(username));
    }

    @PostMapping("/contributionsToBeCheckReviewedSecondly")
    public ResponseEntity<List<Contribution>> contributionsToBeCheckReviewedSecondly(@RequestBody String username) {
        return ResponseEntity.ok(distributeService.contributionsToBeCheckReviewedSecondly(username));
    }

    @PostMapping("/allDistributionInThisConference")
    public ResponseEntity<List<Distribution>> allDistributionInThisConference(@RequestBody String meetingFullName) {
        return ResponseEntity.ok(distributeService.allDistributionInThisConference(meetingFullName));
    }
}
